package com.scc.entites;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@Entity
@Table(name = "CATEGORIES")
public class CategoriesEntity implements Serializable
{
   /**
    * 
    */
   private static final long serialVersionUID = 1L;
   
   private Long id;
   private String code;
   private String name;
   private List<DishEntity> dishes = new ArrayList<DishEntity>();
   
   public CategoriesEntity()
   {
      
   }
   
   public CategoriesEntity(String code, String name)
   {
      this.code = code;
      this.name = name;
   }
   
   @Id
   @Column(name = "CAT_ID")
   @SequenceGenerator(name = "SEQ_CATEGORIES_ID", sequenceName = "SEQ_CATEGORIES_ID")
   @GeneratedValue(generator = "SEQ_CATEGORIES_ID")
   public Long getId()
   {
      return id;
   }
   public void setId(Long id)
   {
      this.id = id;
   }
   
   @Column(name = "CAT_CODE")
   public String getCode()
   {
      return code;
   }
   public void setCode(String code)
   {
      this.code = code;
   }
   
   @Column(name = "CAT_NAME")
   public String getName()
   {
      return name;
   }
   public void setName(String name)
   {
      this.name = name;
   }
   
   @OneToMany(mappedBy="category", fetch = FetchType.EAGER, cascade= CascadeType.ALL)
   public List<DishEntity> getDishes()
   {
      return dishes;
   }

   public void setDishes(List<DishEntity> dishes)
   {
      this.dishes = dishes;
   }

   @Override
   public String toString()
   {
      return "CategoriesEntity [id=" + id + ", code=" + code + ", name=" + name
            + "]";
   }  
}